package com.example.work3.repository;

import com.example.work3.entity.CourseSelection;
import com.example.work3.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface CourseSelectionRepository extends JpaRepository<CourseSelection, Integer>, PagingAndSortingRepository<CourseSelection, Integer> {
    //根据学生id查询选课
   List<CourseSelection> findByStudentId(Integer studentId);
    boolean existsByCourseId(Integer courseId);

    Integer deleteByStudentIdAndCourseId(Integer studentId, Integer courseId);
    //学生id和课程名
    Page<CourseSelection> findAllByStudent_IdAndCourse_Name(Integer studentId, String courseName,Pageable pageable);
    //学号
    Page<CourseSelection> findAllByStudent_Id(Integer studentId, Pageable pageable);
    //课程名
    Page<CourseSelection> findAllByCourse_Name(String courseName, Pageable pageable);
}
